#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
	char haabMonthes[19][10] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"};
	char tzolkinDays[20][10] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
	int n;
	cin>>n;

	cout<<n<<endl;
	for (int i = 0; i < n; i++) {
		string numberOfTheDayStr;
		string month;
		int year;
		cin>>numberOfTheDayStr>>month>>year;
		numberOfTheDayStr.erase(numberOfTheDayStr.size() - 1, 1);
		int numberOfTheDay;
		sscanf(numberOfTheDayStr.c_str(), "%d", &numberOfTheDay);

		int monthIdx = -1;
		for (monthIdx = 0; monthIdx < 19; monthIdx++) {
			if (!strcmp(month.c_str(), haabMonthes[monthIdx]))
				break;				
		}
		int days = numberOfTheDay + monthIdx * 20 + year * 365;

		int tzolkinYear = days / 260;

		days %= 260;
		int numberDay = days % 13 + 1;
		int numberDay1 = days % 20;
		char *dayName = tzolkinDays[numberDay1];
		
		cout<<numberDay<<" "<<dayName<<" "<<tzolkinYear<<endl;

	}
	return 0;
}